<template>
    <div>
        <h1>新增会员</h1>
        <tbody class="table">
        <tbody>
            <tr>
                <td>Img</td>
                <td>
                    <input type="file" @change="upload">
                    <img style="height: 60px;width: 60px;" :src="axios.defaults.baseURL + data.Img">
                </td>
            </tr>
            <tr>
                <td>Uname</td>
                <td>
                    <input type="text" v-model="data.Uname">
                </td>
            </tr>
            <tr>
                <td>Pwd</td>
                <td>
                    <input type="password" v-model="data.password">
                </td>
            </tr>
            <tr>
                <td>password</td>
                <td> <input type="password" v-model="data.password"></td>
            </tr>
            <tr>
                <td>Xid</td>
                <td>
                    <select v-model="data.levelId">
                        <option value="0">选择学历</option>
                        <option value="1">小学</option>
                        <option value="1">大班</option>
                        <option value="1">初中</option>
                        <option value="1">高中</option>
                        <option value="1">中专</option>
                        <option value="1">大专</option>
                        <option value="1">大学</option>
                        <option value="1">博士</option>
                        <option value="1">博士后</option>
                    </select>

                </td>
            </tr>
            <tr>
                <td>SR</td>
                <td> <input type="date" v-model="data.SR"></td>
            </tr>
            <tr>
                <td colspan="2">
                    <input type="button" class="btn btn-success" value="新增" @click="saveinfo">
                    <a href="/">返回会员列表</a>
                </td>
            </tr>
        </tbody>
        </tbody>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios'
import{ref} from 'vue'
import {useRouter} from 'vue-router'
const router = useRouter()
//上传
const upload=(abc: any)=>{
    //取文件  创建表单数据对象 把文件保存到表单数据对象
    let f = abc.target.files[0]
    let fd = new FormData();
    fd.append("file", f);

    axios.post("/api/WJSC/UpLoad", fd).then(res => {
        data.value.Img = res.data;
    })
}
const data=ref({
    "Uid": 0,
    "Uname": "string",
    "Password": "string",
    "Img": "string",
    "SR": "2025-06-06T09:02:54.910Z",
    "Xid": 1
})
const saveinfo=()=>{
    axios.post('/api/Scouer/AddUser',data.value).then(res=>{
        if(res.data>0)
    {
        alert("新增成功")
        router.push("/");
    }
    else{
        alert("新增失败...")
    }
    })
}
</script>

<style scoped>

</style>